package com.lmx.repoDomain.tmodel;

import java.util.List;

import io.katharsis.resource.annotations.JsonApiIncludeByDefault;
import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToMany;
import io.katharsis.resource.annotations.JsonApiToOne;

/**
 *
 *
 */
@JsonApiResource(type = "specservice")
public class SpecService extends BaseEntity implements Comparable<SpecService> {

	private CustomerDrugProjectItem project;

	private NursingPlanDetail item;

	private CustomerDrugProjectExe drugExe;

	private NursingProjectServiceItem projectItem;

	private List<NursingPlanExecute> itemExes;
	
	private String remark;

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@JsonApiToMany
	@JsonApiIncludeByDefault
	public List<NursingPlanExecute> getItemExes() {
		return itemExes;
	}

	public void setItemExes(List<NursingPlanExecute> itemExes) {
		this.itemExes = itemExes;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	public CustomerDrugProjectExe getDrugExe() {
		return drugExe;
	}

	public void setDrugExe(CustomerDrugProjectExe drugExe) {
		this.drugExe = drugExe;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	public NursingProjectServiceItem getProjectItem() {
		return projectItem;
	}

	public void setProjectItem(NursingProjectServiceItem projectItem) {
		this.projectItem = projectItem;
	}

	@Override
	public int compareTo(SpecService o) {
		long date1 = this.getDate();

		long date2 = o.getDate();

		if (date1 == date2) {
			return 0;
		}
		if (date1 < date2) {
			return -1;
		}
		if (date1 > date2) {
			return 1;
		}
		return 0;

	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	public CustomerDrugProjectItem getProject() {
		return project;
	}

	public void setProject(CustomerDrugProjectItem project) {
		this.project = project;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	public NursingPlanDetail getItem() {
		return item;
	}

	public void setItem(NursingPlanDetail item) {
		this.item = item;
	}

	public long getDate() {
		if (this.getItem() != null) {
			return Long.parseLong(this.getItem().getStartTimeTab());
		}
		if (this.getProject() != null) {
			return Long.parseLong(this.getProject().getUseDrugDate());
		}
		return 0;
	}

}
